import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';

export interface DragData { // 数据结构
  tag: string; // 区分是哪一级拖拽
  data: any; // 传递的数据
}
@Injectable()
export class DragDropService {
  private _dragData = new BehaviorSubject<DragData>(null); // BehaviorSubject总能记住上一次的值

  setDragData(data: DragData) {
    this._dragData.next(data);
  }
  getDragData(): Observable<DragData> {
    return this._dragData.asObservable();
  }
  clearDragData() {
    this._dragData.next(null);
  }
  constructor() { }
}
